/**
 * Created with IntelliJ IDEA.
 * Description:join线程等待
 * User: lenovo
 * Date: 2022-09-05
 * Time: 22:59
 */
public class Demo11 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            for (int i = 0; i < 5; i++) {
                System.out.println("hello thred");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        t.start();
        System.out.println("main 线程 join前");
        t.join();//main线程在调用join方法后,会进入阻塞状态,直到t线程执行完成后进入就绪状态
        System.out.println("main 线程 在执行后");
    }
}
